home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / comdem / receive.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  4.0 KB  |  136 lines

  1. VERSION 2.00
  2. Begin Form Receive 
  3.    Caption         =   "Communication Demo - Receive Window"
  4.    ClientHeight    =   1890
  5.    ClientLeft      =   1215
  6.    ClientTop       =   4635
  7.    ClientWidth     =   5445
  8.    Height          =   2295
  9.    Icon            =   0
  10.    Left            =   1155
  11.    LinkMode        =   1  'Source
  12.    LinkTopic       =   "Form5"
  13.    ScaleHeight     =   1890
  14.    ScaleWidth      =   5445
  15.    Top             =   4290
  16.    Width           =   5565
  17.    Begin TextBox Transmit_Text 
  18.       BackColor       =   &H00FFFFFF&
  19.       ForeColor       =   &H00000000&
  20.       Height          =   570
  21.       Left            =   105
  22.       MultiLine       =   -1  'True
  23.       ScrollBars      =   1  'Horizontal
  24.       TabIndex        =   1
  25.       Top             =   1185
  26.       Width           =   4695
  27.    End
  28.    Begin Timer Receive_Timer 
  29.       Left            =   4905
  30.       Top             =   120
  31.    End
  32.    Begin TextBox Receive_Text 
  33.       Height          =   855
  34.       Left            =   105
  35.       MultiLine       =   -1  'True
  36.       ScrollBars      =   3  'Both
  37.       TabIndex        =   0
  38.       Top             =   120
  39.       Width           =   4695
  40.    End
  41. Dim MinWindowSize As Integer
  42. Sub Form_Load ()
  43.     Height = Screen.Height / 2
  44.     Width = Screen.Width * .75
  45.     Top = Screen.Height * .25
  46.     Left = (Screen.Width - Width) / 2
  47.     Receive_Text.Text = ""
  48.     Transmit_Text.Text = ""
  49.     Initialize
  50. End Sub
  51. Sub Form_Paint ()
  52.     PaintText
  53. End Sub
  54. Sub Form_Resize ()
  55.     Work% = ScaleHeight - MinWindowSize
  56.     If Work% < 0 Then
  57.         Height = Height + Abs(Work%)
  58.     End If
  59.     Initialize
  60. End Sub
  61. Sub Form_Unload (Cancel As Integer)
  62.     If CommDemo.Menu_Windows.Enabled Then
  63.         CommDemo.Menu_Window_Receive_Transmit.Checked = False
  64.         Hide
  65.         Cancel = True
  66.         Exit Sub
  67.     End If
  68. End Sub
  69. Sub Initialize ()
  70.     ForeColor = &HFFFFFF
  71.     Text$ = "Receive Window"
  72.     FontSize = 10
  73.     tHeight = TextHeight(Text$)
  74.     tWidth = TextWidth(Text$)
  75.     CurrentX = (ScaleWidth - tWidth) \ 2
  76.     CurrentY = tHeight * .5
  77.     Transmit_Text.Move 0, ScaleHeight - Transmit_Text.Height, ScaleWidth, Transmit_Text.Height
  78.     Receive_Text.Top = tHeight * 2
  79.     MinWindowSize = Receive_Text.Top
  80.     Receive_Text.Move 0, Receive_Text.Top, ScaleWidth, ScaleHeight - (Transmit_Text.Height + Receive_Text.Top + tHeight * 2)
  81.     Text$ = "Transmit Window"
  82.     FontSize = 10
  83.     tHeight = TextHeight(Text$)
  84.     tWidth = TextWidth(Text$)
  85.     CurrentX = (ScaleWidth - tWidth) \ 2
  86.     CurrentY = Transmit_Text.Top - tHeight * 1.5
  87.     ForeColor = &H0
  88.     MinWindowSize = MinWindowSize + (ScaleHeight - CurrentY) * 2
  89. End Sub
  90. Sub PaintText ()
  91.     Cls
  92.         
  93.     ForeColor = &H0
  94.     Text$ = "Receive Window"
  95.     FontSize = 10
  96.     tHeight = TextHeight(Text$)
  97.     tWidth = TextWidth(Text$)
  98.     CurrentX = (ScaleWidth - tWidth) \ 2
  99.     CurrentY = tHeight * .5
  100.     Print Text$
  101.     Text$ = "Transmit Window"
  102.     FontSize = 10
  103.     tHeight = TextHeight(Text$)
  104.     tWidth = TextWidth(Text$)
  105.     CurrentX = (ScaleWidth - tWidth) \ 2
  106.     CurrentY = Transmit_Text.Top - tHeight * 1.5
  107.     Print Text$
  108. End Sub
  109. Sub Receive_Text_KeyPress (KeyAscii As Integer)
  110.     KeyAscii = 0
  111. End Sub
  112. Sub Receive_Timer_Timer ()
  113.     a$ = ReadCommPort(128)
  114.     If Len(a$) > 0 Then
  115.         Receive_Text.selstart = Len(Receive_Text.Text) + 1
  116.         Receive_Text.sellength = 0
  117.         Receive_Text.seltext = a$
  118.     End If
  119. End Sub
  120. Sub Transmit_Text_KeyPress (KeyAscii As Integer)
  121.     If KeyAscii = 13 Then
  122.        If CommDemo.Menu_Comm_Send_CRLF.Checked = True Then
  123.           Work$ = Chr$(13) + Chr$(11)
  124.        Else
  125.           Work$ = Chr$(13)
  126.        End If
  127.        WriteCommPort Transmit_Text.Text + Work$
  128.        Transmit_Text.Text = ""
  129.        KeyAscii = 0
  130.     End If
  131.     ' Remove the BEEP for CTRL characters
  132.     If KeyAscii < 32 Then
  133.        KeyAscii = 0
  134.     End If
  135. End Sub
  136.